<div id="account-settings" class="settings-section show" data-name="account-and-privacy">
    <div class="alert" id="dev-account-settings-status"></div>
    <div class="account-settings-form">
        <div class="inline-block">
            <div id="user_details_section">
                <h3 class="inline-block account-settings-heading">{{t "Account" }}</h3>
                <div class="alert-notification account-alert-notification" id="account-settings-status"></div>
                <form class="grid">
                    {{#if user_has_email_set}}
                    <div class="input-group">
                        <label class="inline-block title">{{t "Email" }}</label>
                        <div id="change_email_button_container" class="inline-block {{#unless user_can_change_email}}disabled_setting_tooltip{{/unless}}">
                            <button id="change_email_button" type="button" class="button btn-link small rounded inline-block" {{#unless user_can_change_email}}disabled="disabled"{{/unless}}>
                                {{page_params.delivery_email}}
                                <i class="fa fa-pencil"></i>
                            </button>
                        </div>
                    </div>
                    {{else}}
                    {{! Demo organizations before the owner has configured an email address. }}
                    <div class="input-group">
                        <p>
                            {{#tr}}
                                Add your email to <z-link-invite-users-help>invite other users</z-link-invite-users-help>
                                or <z-link-convert-demo-organization-help>convert to a permanent Zulip organization</z-link-convert-demo-organization-help>.
                                {{#*inline "z-link-invite-users-help"}}<a href="/help/invite-new-users" target="_blank" rel="noopener noreferrer">{{> @partial-block}}</a>{{/inline}}
                                {{#*inline "z-link-convert-demo-organization-help"}}<a href="/help/demo-organizations#convert-a-demo-organization-to-a-permanent-organization" target="_blank" rel="noopener noreferrer">{{> @partial-block}}</a>{{/inline}}
                            {{/tr}}
                        </p>
                        <button id="demo_organization_add_email_button" type="button" class="button rounded sea-green">
                            {{t "Add email"}}
                        </button>
                    </div>
                    {{/if}}
                </form>

                {{#if page_params.two_fa_enabled }}
                <p for="two_factor_auth" class="inline-block title">
                    {{t "Two factor authentication" }}: {{#if page_params.two_fa_enabled_user }}{{t "Enabled" }}{{else}}{{t "Disabled" }}{{/if}}
                    <a target="_blank" rel="noopener noreferrer" id="two_factor_auth" href="/account/two_factor/" title="{{t 'Set up two factor authentication' }}">[{{t "Setup" }}]</a>
                </p>
                {{/if}}

                <form class="password-change-form grid">
                    {{#if user_can_change_password}}
                    <div>
                        <label class="inline-block title">{{t "Password" }}</label>
                        <div class="input-group inline-block" id="pw_change_link">
                            <button id="change_password" type="button" class="change_password_button btn-link small button rounded inline-block" data-dismiss="modal">********<i class="fa fa-pencil"></i></button>
                        </div>
                    </div>
                    {{/if}}
                </form>

                <div class="input-group">
                    <div id="deactivate_account_container" class="inline-block {{#if user_is_only_organization_owner}}disabled_setting_tooltip{{/if}}">
                        <button type="submit" class="button rounded btn-danger" id="user_deactivate_account_button"
                          {{#if user_is_only_organization_owner}}disabled="disabled"{{/if}}>
                            {{t 'Deactivate account' }}
                        </button>
                    </div>
                    {{#if owner_is_only_user_in_organization}}
                        <button type="submit" class="button rounded btn-danger deactivate_realm_button">
                            {{t 'Deactivate organization' }}
                        </button>
                    {{/if}}
                </div>
            </div>
        </div>

        <div id="privacy_settings_box">
            <h3 class="inline-block">{{t "Privacy" }}</h3>
            <div class="alert-notification privacy-setting-status"></div>
            <div class="input-group">
                {{> settings_checkbox
                  setting_name="send_private_typing_notifications"
                  is_checked=settings_object.send_private_typing_notifications
                  label=settings_label.send_private_typing_notifications
                  }}
                {{> settings_checkbox
                  setting_name="send_stream_typing_notifications"
                  is_checked=settings_object.send_stream_typing_notifications
                  label=settings_label.send_stream_typing_notifications
                  }}
                {{> settings_checkbox
                  setting_name="send_read_receipts"
                  is_checked=settings_object.send_read_receipts
                  label=settings_label.send_read_receipts
                  tooltip_text=send_read_receipts_tooltip
                  hide_tooltip=page_params.realm_enable_read_receipts
                  help_link="/help/read-receipts"
                  }}
                {{> settings_checkbox
                  setting_name="presence_enabled"
                  is_checked=settings_object.presence_enabled
                  label=settings_label.presence_enabled
                  label_parens_text=settings_label.presence_enabled_parens_text
                  help_link="/help/status-and-availability"
                  prefix="user_"}}
            </div>
            <div class="input-group">
                <label for="email_address_visibility" class="dropdown-title">{{t "Who can access your email address" }}
                    {{> ../help_link_widget link="/help/configure-email-visibility" }}
                </label>
                <div id="user_email_address_dropdown_container" class="inline-block {{#unless user_has_email_set}}disabled_setting_tooltip{{/unless}}">
                    <select name="email_address_visibility" class="email_address_visibility prop-element settings_select bootstrap-focus-style" data-setting-widget-type="number"
                      id="user_email_address_visibility" {{#unless user_has_email_set}}disabled="disabled"{{/unless}}>
                        {{> dropdown_options_widget option_values=email_address_visibility_values}}
                    </select>
                </div>
            </div>
        </div>

        <hr class="settings_separator" />

        <div id="api_key_button_box">
            <h3>{{t "API key" }}</h3>

            <div class="input-group">
                <p class="api-key-note">
                    {{#tr}}
                    An API key can be used to programmatically access a Zulip account.
                    Anyone with access to your API key has the ability to read your messages, send
                    messages on your behalf, and otherwise impersonate you on Zulip, so you should
                    guard your API key as carefully as you guard your password. <br />
                    We recommend creating bots and using the bots' accounts and API keys to access
                    the Zulip API, unless the task requires access to your account.
                    {{/tr}}
                </p>
                <div id="api_key_button_container" class="inline-block {{#unless user_has_email_set}}disabled_setting_tooltip{{/unless}}">
                    <button class="button rounded" id="api_key_button" {{#unless user_has_email_set}}disabled="disabled"{{/unless}}>
                        {{t "Show/change your API key" }}
                    </button>
                </div>
            </div>
        </div>
        <!-- Render /settings/api_key_modal.hbs after #api_key_button is clicked
        to avoid password being inserted by password manager too aggressively. -->
    </div>
</div>
